<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>订单列表</title>
<link rel="stylesheet" href="/layui/css/layui.css">
<script src="/static/js/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
<style>body{background:#f5f5f5;padding:20px;}</style>
</head>
<body>
<div class="layui-card"><div class="layui-card-header">订单列表</div><div class="layui-card-body">
<div class="layui-form layui-form-pane" style="margin-bottom:15px;"><div class="layui-inline"><input type="text" id="orderNo" placeholder="订单号" class="layui-input" value="<?= htmlspecialchars($orderNo) ?>"></div><div class="layui-inline"><select id="payStatus"><option value="-1" <?= $payStatus==-1?'selected':'' ?>>全部状态</option><option value="0" <?= $payStatus===0?'selected':'' ?>>未支付</option><option value="1" <?= $payStatus===1?'selected':'' ?>>已支付</option><option value="2" <?= $payStatus==2?'selected':'' ?>>已失效</option></select></div><button class="layui-btn layui-btn-primary layui-btn-sm" onclick="search()">搜索</button></div>
<table class="layui-table" lay-size="sm"><thead><tr><th>订单号</th><th>用户</th><th>套餐名称</th><th>金额</th><th>支付状态</th><th>支付方式</th><th>购买时间</th><th>操作</th></tr></thead>
<tbody><?php foreach($list as $item): ?><tr><td><?= $item['order_no'] ?></td><td><?= $item['username'] ?></td><td><?= $item['package_name'] ?></td><td>¥<?= number_format($item['amount'],2) ?></td><td><?php if($item['pay_status']==1)echo'<span style="color:green">已支付</span>';elseif($item['pay_status']==2)echo'<span style="color:red">已失效</span>';else echo'<span style="color:orange">未支付</span>';?></td><td><?= $item['pay_type']??'-' ?></td><td><?= $item['create_time'] ?></td><td><?php if($item['pay_status']==0):?><button class="layui-btn layui-btn-xs layui-btn-warm" onclick="confirmPay(<?=$item['id']?>)">确认支付</button><?php endif;?></td></tr><?php endforeach; ?><?php if(empty($list)):?><tr><td colspan="8" style="text-align:center;color:#999;">暂无数据</td></tr><?php endif;?></tbody></table>
<div id="page"></div></div></div>
<script>
var total=<?=$total?>,page=<?=$page?>,pageSize=<?=$pageSize?>;
layui.use('laypage',function(){var p=layui.laypage;if(total>pageSize){p.render({elem:'page',count:total,limit:pageSize,curr:page,jump:function(o,f){if(!f) location.href='/admin/order/index?page='+o.curr+'&order_no=<?=urlencode($orderNo)?>&pay_status=<?=$payStatus?>';}});}});
function search(){location.href='/admin/order/index?order_no='+encodeURIComponent($('#orderNo').val())+'&pay_status='+$('#payStatus').val();}
function confirmPay(id){layer.confirm('确认该订单已支付？',function(){$.post('/admin/order/confirmPay',{id:id},function(res){layer.msg(res.msg,{icon:res.code===0?1:2});if(res.code===0) setTimeout(function(){location.reload();},1000);});});}
</script>
</body>
</html>